package com.pn.service.impl;

import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.pn.mapper.RoleAuthMapper;
import com.pn.service.RoleAuthService;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class RoleAuthServiceImpl implements RoleAuthService{

    @Resource
    private RoleAuthMapper roleAuthMapper;

    @Override
    public List<Integer> findAidByRid(Integer roleId) {
        return roleAuthMapper.selectAuthIdByRid(roleId);
    }

    @Transactional
    @Override
    public int modifyRoleAuth(Integer roleId, Integer[] authIds) {
        int i = roleAuthMapper.deleteRoleAuthByRid(roleId);
        int count = 0;
        for (int authId:authIds){
           count += roleAuthMapper.insertRoleAuth(roleId,authId);
        }
        return count;
    }
}
